//
//  JYMainViewController.swift
//  WeiBoDemo
//
//  Created by 万佳阳 on 16/8/1.
//  Copyright © 2016年 JYWan. All rights reserved.
//

import UIKit

class JYMainViewController: UITabBarController {
    // MARK:- 懒加载属性
    private lazy var composeBtn = UIButton(imageName: "tabbar_compose_icon_add", bgImageName: "tabbar_compose_button")
    
    // MARK:- 系统回调函数
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupComposeBtn()
    

    }
}

// MARK:- 设置UI界面
extension JYMainViewController {

    ///设置发布按钮
    private func setupComposeBtn() {
        //添加按钮
        tabBar.addSubview(composeBtn)
        
        //设置位置
        composeBtn.center = CGPointMake(tabBar.center.x, tabBar.bounds.size.height * 0.5)
        
        //监听发布按钮点击
        composeBtn.addTarget(self, action: #selector(JYMainViewController.composeBtnClick), forControlEvents: .TouchUpInside)
        
    }

}

// MARK:- 事件监听
extension JYMainViewController {
    
    @objc private func composeBtnClick() {
        //创建发布控制器
        let composeVc = JYComposeViewController()
        
        //包装导航控制器器
        let composeNav = UINavigationController(rootViewController: composeVc)
        
        //弹出控制器
        presentViewController(composeNav, animated: true, completion: nil)
        
        
    }
}